package com.zy.chapter5

/**
 * @author: zhaoyi
 * @create: 2020-04-27 21:51
 * @description: ${description}
 **/
object InnerClassTest extends App {

  val aa = new InnerClass()
  val bb = new InnerClass()

  val aaInner = aa.join("AA")
  val bbInner = bb.join("AA")

  aa.innerMembers.+=(aaInner)
  //每个InnerClass实例都有自己的Inner类 下面这样是失败编译不过的
  //aa.innerMembers.+=(bbInner)

  val aaObject = aa.joinObjectMem("object-A")
  val bbObject = bb.joinObjectMem("object-B")
  ////伴生对象里面的内部类是同一个类
  aa.innerObjectMembers.+=(bbObject)


  //  aa.innerMembers.+=(aaInner)
  //  aaInner.inners.+=(aaInner)
  //  //每个InnerClass实例都有自己的Inner类
  //  //aa.innerMembers.+=(bbInner)
  //  //bbInner.inners.+=(aaInner)
  //  aaInner.inners.foreach(println)
  //
  //  println("=========================")
  //
  //  val aaObject = aa.joinObjectMem("object-A")
  //  val bbObject = bb.joinObjectMem("object-B")
  //  //伴生对象里面的类大家 跟上面的内部类不同
  //  aaObject.inners.+=(aaObject)
  //  aaObject.inners.+=(bbObject)
  //
  //  aaObject.inners.foreach(println)
  //
  //  println("=========================")
  //  val out = new InnerOutClass("外部类")
  //  out.join("内部")


}
